package jifenbao.com.jifenbao;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import jifenbao.com.jifenbao.dialog.DialogForRedeem;
import jifenbao.com.jifenbao.dialog.RedeemInterface;

/**
 * Created by Administrator on 2016/5/25 0025.
 */
public class CouponDetail extends Activity{
    private Button btn_rightnow;
    private DialogForRedeem buttonDialog;
    private TextView detail_value,detail_name,detail_full,suitshops;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_coupon_detail);

        btn_rightnow = (Button)findViewById(R.id.use_rightnow_btn);
        detail_name = (TextView)findViewById(R.id.coupon_detail_name);
        detail_value = (TextView)findViewById(R.id.coupon_detail_value);
        detail_full = (TextView)findViewById(R.id.coupon_detail_full);
        suitshops = (TextView)findViewById(R.id.suit_shops);

        putListText();
        changeButton();
        suitstoreListener();
    }

    public void putListText(){
        Intent intent = getIntent();
        detail_value.setText(intent.getStringExtra("value"));
        detail_name.setText(intent.getStringExtra("name"));
        detail_full.setText(intent.getStringExtra("full"));
    }

    public void changeButton(){
        btn_rightnow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                buttonDialog = new DialogForRedeem(CouponDetail.this);
                buttonDialog.show();
                buttonDialog.setRedeemSucceed(new RedeemInterface() {
                    @Override
                    public void onRedeemSucceed() {
                        btn_rightnow.setEnabled(false);
                        btn_rightnow.setText("已使用");
                    }
                });
            }
        });
    }

    public void suitstoreListener(){
        suitshops.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent saveintent = new Intent(CouponDetail.this,ShopList.class);
                startActivity(saveintent);
            }
        });
    }
}


